package com.example.mapp;

import com.example.entity.supervision.PlanDict;
import com.example.mapp.buildSql.SupervisionMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created by simon on 2018/8/7.
 */
@Mapper
public interface PlanDictMapp {

    @Insert(" insert into plan_dict (pd_name, pd_type, p_party_id, p_party_name, p_user_id, p_user_name, p_start_dt, p_end_dt, ext1, ext2) " +
            " value (#{pdName},#{pdType},#{pPartyId},#{pPartyName},#{pUserId},#{pUserName},#{pStartDt},#{pEndDt},#{ext1},#{ext2}) ")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
    int insert(PlanDict planDict) throws Exception;

    @Delete("delete from plan_dict where id=#{id}")
    int delete(String id)throws Exception;

    @Update("update plan_dict set pd_name=#{pdName},pd_type=#{pdType}, p_party_id=#{pPartyId}, p_party_name=#{pPartyName}, p_user_id=#{pUserId}, " +
            "p_user_name=#{pUserName}, p_start_dt=#{pStartDt}, p_end_dt=#{pEndDt}, ext1=#{ext1}, ext2=#{ext2} where id=#{id} ")
    int update(Map planDict) throws Exception;

    @SelectProvider(type = SupervisionMappSql.class, method = "queryPlanDict")
    List<PlanDict> query(PlanDict map) throws Exception;
}
